package structuralpattern.proxypattern;
/**
 * 邢帅教育
 * <p>
 * 本源代码由数据中心及其作者共同所有，未经版权持有者的事先书面授权，
 * 不得使用、复制、修改、合并、发布、分发和/或销售本源代码的副本。
 *
 * @copyright Copyright (c) 2018. xsteach.com all rights reserved.
 */

/**
 * @author maikec
 * @date 2018/9/11
 */
public class Proxy implements Subject {
    private RealSubject subject;

    public Proxy() {

    }

    @Override
    public void request() {
        if (null == subject) {
            subject = new RealSubject();
        }
        preRequest();
        subject.request();
        afterRequest();
    }

    private void preRequest() {
        System.out.println( "Proxy#preRequest" );
    }

    private void afterRequest() {
        System.out.println( "Proxy#afterRequest" );
    }
}
